package com.jintian.smart.kernel.core.auth;

import java.io.Closeable;
import java.io.IOException;

/**
 * 提供登录用信息
 */
public interface IOperatorProvider {
	IOperator currentOperator();

	IOperator getOperator(String id);

	Closeable changeOperator(String userId);

	Closeable administrator();

	default void administrator(Runnable runnable) {
		Closeable c = null;
		try {
			c = this.administrator();
			runnable.run();
		} finally {
			if (c != null) {
				try {
					c.close();
				} catch (IOException e) {
				}
			}
		}
	}

}
